package com.youle.robots.gateway.rest;

import com.alibaba.dubbo.config.annotation.Reference;
import com.youle.robots.common.model.UserBasiceInfo;
import com.youle.robots.common.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 * User: kedong
 * Date: 18-3-19
 * Time: 下午5:22
 * To change this template use File | Settings | File and Code Templates ->Includes->File Header.
 */
@Api(tags = "用户管理", description = "UserController")
@RestController
@RequestMapping("/api/user")
public class Dome {

    @Reference
    private UserService userService;

    @ApiOperation(value = "通过名称查找")
    @GetMapping(value = "/{userId}")
    public ResponseEntity<UserBasiceInfo> findByName(
            @ApiParam(value = "用户ID", required = true)
            @PathVariable("userId") Integer id
    ) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("code", "1");
        return (ResponseEntity<UserBasiceInfo>) new ResponseEntity(userService.findByName(id), headers,
                HttpStatus.FORBIDDEN);
    }
}
